﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="/static/css/angularStyle.css" />
    <link rel="stylesheet" href="/static/css/common/reset.css" />
    <link rel="stylesheet" href="/static/css/associate.css" />
    <link rel="stylesheet" href="/static/css/ng-pagination.min.css" />
    <link rel="stylesheet" href="/static/css/sweetalert.min.css" />
    <title>宾果高校</title>
</head>
<body>
    <div class="associate">
        <div id="divHeader"></div>
        <section class="assoc-content container clearfix">
            <div class="assoc-c-left fl">

                <div id="divNavigation"></div>
            </div>
            <div class="assoc-c-right fr" ng-app="myApp">
                <div class="assoc-cr-underActivity" ng-controller="contractCtrl">
                    <ul class="assoc-cru-title clearfix" id="contract-cru-title">
                        <li class="active">进行中</li>
                        <li>历史活动</li>
                    </ul>
                    <table class="assoc-cru-content mt10">
                        <thead class="assoc-cru-list mt5 borderbtm">
                            <tr>
                                <th class="">活动名称</th>
                                <th>合同确定时间</th>
                                <!--<p>企业付款</p>
                                <p>社团首款</p>-->
                                <th id="pName">合作企业</th>
                                <th id="pAssoc" class="hide">邀请社团</th>
                                <th id="pAmount">赞助金总额</th>
                                <th>查看详情</th>
                            <tr>
                        </thead>
                        <tbody class="assoc-cruc-tab" ng-cloak>
                            <tr class="assoc-cru-list clearfix" ng-repeat="x in names">
                                <td>{{x.ProjectName}}</td>
                                <td>{{x.SignDate | date:'yyyy-MM-dd'}}</td>
                                <!--<p>已付款</p>
                                <p>已查收</p>-->
                                <td>{{x.ContractorName}}</td>
                                <td id="pAssocName" class="hide">{{x.CreatorName}}</td>
                                <td>{{x.Amount}}</td>
                                <td>
                                    <a href="contractDetail.html?id={{x.ContractID}}" class="assoc-crul-check">点击查看</a>
                                    <!--<span id="divDelete" class="hide"><a href="javascript:void(0)" onclick="DeleteContract(this)" tag="{{x.ContractID}}" class="assoc-crul-delete ml15"></a></span>-->
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="page">
                        <div class="center">
                            <pager page-count="pageCount" current-page="currentPage" on-page-change="onPageChange()" first-text="首页" next-text="下一页" prev-text="上一页" last-text="尾页"></pager>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <div id="divFooter"></div>
</body>
</html>

<script type="text/javascript" src="/static/js/ref/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="/static/js/self/common.js"></script>
<script type="text/javascript" src="/static/js/ref/angular.min.js"></script>
<script type="text/javascript" src="/static/js/ref/ng-pagination.min.js"></script>
<script src="/static/js/ref/sweetalert.min.js"></script>
<script>

    var userType = common.GetUserType();
    if (!common.checkValue(userType))
        window.location = "/login.html";

    $("#divHeader").load("/wuc/header.html");
    $("#divFooter").load("/wuc/footer.html");
    $("#divNavigation").load("/wuc/navigation.html");

    switch (userType) {
        case 1:
            $("#pName").html("合作社团");
            break;
        case 3:
            $("#pName").html("赞助企业");
            $("#pAmount").html("代理官奖金");
            $("#pAssoc").show();
            $("#pAssocName").show();
            break;
    }

    var values = {};
    values.Limit = 10;
    values.Start = 1;
    values.Status = "Effective";

    common.CreatePagingCtrl({ name: 'contractCtrl', limit: 10, pageChanged: ChangePage });

    function AfterCompleted(ctx) {
        if (ctx == null) {
            common.alertMessage("无数据.");
            return;
        }

        var ele = document.querySelector("[ng-controller=contractCtrl]");

        angular.element(ele).scope().update(ctx);
    }

    common.commonAjax({ type: 'Post', url: '/api/project/ListContractByStatus', data: values, sMethod: AfterCompleted });

    function ChangePage($scope) {

        values.Start = $scope.currentPage;

        common.commonAjax({ type: 'Post', url: '/api/project/ListContractByStatus', data: values, sMethod: AfterCompleted });
    }

    //function DeleteContract(obj) {
    //    var pars = {};
    //    pars.ContractID = $(obj).attr("tag");
    //    pars.Status = "Deleted";
    //    common.commonAjax({ type: 'Post', url: '/api/project/CancelContract', data: pars, sMethod: AfterDeleted });
    //}

    //function AfterDeleted(ctx) {
    //    if (ctx == null) {
    //        common.alertMessage("无数据.");
    //        return;
    //    }

    //    common.showMessage("操作成功", function () {
    //        window.location = "contract.html";
    //    })
    //}

    $("#contract-cru-title li").on('click', function (e) {
        var self = $(this);
        var index = $(this).index();
        self.siblings().removeClass('active');
        self.addClass('active');
        if (index == 0) {
            values.Status = "Effective";
            values.Start = 1;
            common.commonAjax({ type: 'Post', url: '/api/project/ListContractByStatus', data: values, sMethod: AfterCompleted });
        }
        else {
            values.Status = "Closed";
            values.Start = 1;
            common.commonAjax({ type: 'Post', url: '/api/project/ListContractByStatus', data: values, sMethod: AfterCompleted });
        }
    });

</script>

